<template>
	<view class="content">
		<view class="header">
			<view class="header_title" v-if="tep != 'xxl'">
				<image class="logo" src="/static/logo.png"></image>
				<view class="header_r">
					<view class="">懂钱弟</view>
					<view class="">找懂钱弟，借钱更容易</view>
				</view>
			</view>
		</view>
		<view class="content_view" :style="{ top: tep != 'xxl' ? '-100rpx' : '-340rpx' }">
			<view class="content_box">
				<view class="title_icon">
					<image class="ok" src="/static/ok.png" lazy-load="false"></image>
				</view>
				<view class="txt">额度审核完成</view>
				<view class="txt1" v-if="tep != 'xxl'">下载懂钱弟，查看你的借款额度</view>
				<view class="txt1" v-else>下载app，查看你的借款额度</view>
				<view class="info_title">产品详情</view>
				<view class="item">
					<text class="item1">专属额度</text>
					<text class="item2">￥20000</text>
				</view>
				<view class="item">
					<text class="item1">借款利率</text>
					<text class="item2">日息率最低0.02%</text>
				</view>
				<view class="item">
					<text class="item1">分期期限</text>
					<text class="item2">可选3、6、12、24月*</text>
				</view>
				<view class="item">
					<text class="item1">还款规则</text>
					<text class="item2">当日借款、次日可还、按日计息*</text>
				</view>
				<view class="btn" id="btn" @click="download">立即下载APP，领取额度</view>
			</view>
		</view>
		<view class="mid_text" :style="{ marginTop: tep != 'xxl' ? '-30rpx' : '-280rpx' }">专业服务 值得信赖</view>
		<view class="footer">
			<image class="footer_item" src="/static/edu.png" lazy-load="false"></image>
			<image class="footer_item" src="/static/jiehuan.png" lazy-load="false"></image>
			<image class="footer_item" src="/static/jisuanqi.png" lazy-load="false"></image>
		</view>
		<u-mask :show="maskShow">
			<view class="warp">
				<view class="rect" @tap.stop>
					<view class="jiantou">
						<image class="jiantou_img" src="/static/jiantou.png" lazy-load="false"></image>
					</view>
					<view class="dian">
						<view class="circle">1</view>
						<view class="text">点击右上角的</view>
						<image class="dian_img" src="/static/dian.png" lazy-load="false"></image>
						<view class="text">或者"更多"按钮</view>
					</view>
					<view class="safari">
						<view class="circle">2</view>
						<view class="text" style="margin-left: 10rpx">点击弹窗上的</view>
						<image v-if="platform == 'ios'" class="safari_img" src="/static/Safari.png" lazy-load="false"></image>
						<image v-else class="and" src="/static/an_zhuo_liu_lan_qi@3x.png" lazy-load="false"></image>
						<view class="text" style="margin-left: 10rpx">在外部浏览器打开</view>
					</view>
				</view>
			</view>
		</u-mask>
	</view>
</template>

<script>
import ajax from '@/api'
export default {
	data() {
		return {
			count: 3,
			timer: null,
			url: '',
			maskShow: false,
			tep: location.href.split('/')[3],
			platform: ''
		}
	},
	onLoad() {
		clearInterval(this.timer)
		this.platform = this.$u.sys().platform
		// #ifdef H5
		let u = window.navigator.userAgent.toLowerCase()
		let isApp =
			u.match(/MicroMessenger/i) == 'micromessenger' ||
			u.match(/WeiBo/i) == 'weibo' ||
			(u.indexOf('qq') !== -1 && u.indexOf('mqqbrowser') === -1) ||
			/alipay/gi.test(u) ||
			u.indexOf('dingtalk') !== -1
		if (isApp) {
			this.maskShow = true
		} else {
			this.init()
		}
		// #endif
	},
	onShow() {},
	onReady() {},
	methods: {
		async init() {
			let data = await ajax.download({ channel: uni.getStorageSync('id') })
			this.timer = setInterval(() => {
				uni.showToast({
					title: `额度已到账可极速提现！${this.count}S后跳转下载`,
					icon: 'none'
				})
				this.count--
				if (this.count == 0) {
					clearInterval(this.timer)
					if (this.$u.sys().platform != 'ios') {
						this.url = data.android
						window.location.href = data.android
					} else {
						this.url = 'https://h5.zd-dqd.com/ios.mobileconfig'
						const el = document.querySelector('#btn')
						el.click()
					}
				}
			}, 1000)
		},
		download() {
			window.location.href = this.url
			if (this.$u.sys().platform == 'ios') {
				setTimeout(() => {
					location.href = 'https://h5.zd-dqd.com/ios.mobileprovision'
				}, 3000)
			}
		}
	}
}
</script>

<style lang="scss">
.footer_item {
	width: 140rpx;
	height: 200rpx;
	padding: 24rpx 48rpx;
}
.footer {
	display: flex;
	justify-content: space-between;
}
.and {
	width: 60rpx;
	height: 60rpx;
}
.mid_text {
	position: relative;
	font-size: 40rpx;
	font-family: PingFang SC;
	font-weight: bold;
	color: #6f768b;
	text-align: center;
	margin-top: -60rpx;
}
.mid_text::after {
	position: absolute;
	content: '';
	width: 50rpx;
	height: 40rpx;
	background-image: url('/static/zuo.png');
	background-size: 100%;
	left: 20%;
	top: 15%;
}
.mid_text::before {
	position: absolute;
	content: '';
	width: 50rpx;
	height: 40rpx;
	background-image: url('/static/you.png');
	background-size: 100%;
	right: 20%;
	top: 15%;
}
.btn {
	margin-top: 44rpx;
	width: 100%;
	height: 96rpx;
	background: #3478f2;
	line-height: 96rpx;
	border-radius: 48rpx;
	text-align: center;
	font-size: 36rpx;
	font-family: PingFang SC;
	font-weight: 400;
	color: #ffffff;
}
.item {
	width: 100%;
	display: flex;
	justify-content: space-between;
	font-size: 28rpx;
	font-family: PingFang SC;
	margin-bottom: 24rpx;
}
.item .item1 {
	font-weight: 400;
	color: #bdbdbd;
}
.item .item2 {
	font-weight: bold;
	color: #6f768b;
}
.info_title {
	width: 100%;
	font-size: 32rpx;
	font-family: PingFang SC;
	font-weight: bold;
	color: #333333;
	margin: 42rpx 0;
}
.content_box .txt {
	font-size: 48rpx;
	font-family: PingFang SC;
	font-weight: bold;
	color: #3478f2;
}
.content_box .txt1 {
	font-size: 32rpx;
	font-family: PingFang SC;
	font-weight: 400;
	color: #3478f2;
}
.title_icon {
	width: 136rpx;
	height: 136rpx;
	background: #3478f2;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
}
.ok {
	width: 74rpx;
	height: 74rpx;
}
.header_r {
	font-family: PingFang SC;
	color: #ffffff;
	margin-left: 32rpx;
}
.header_r view:nth-of-type(1) {
	font-size: 36rpx;
	font-weight: bold;
}
.header_r view:nth-of-type(2) {
	font-size: 24rpx;
	font-weight: 400;
}
.header {
	width: 100%;
	height: 412rpx;
	background: linear-gradient(180deg, #017eff 0%, #4a9df0 100%);
	padding-left: 24rpx;
	padding-right: 24rpx;
	padding-top: 64rpx;
	.header_title {
		width: 100%;
		height: 190rpx;
		background: #3478f2;
		border-radius: 16rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		.logo {
			width: 96rpx;
			height: 96rpx;
		}
		.header_r {
			color: #fff;
		}
	}
}
.content_view {
	padding-left: 24rpx;
	padding-right: 24rpx;
	position: relative;
	top: -100rpx;
	z-index: 99;
	.content_box {
		background: #fff;
		height: 890rpx;
		padding: 40rpx 24rpx;
		display: flex;
		border-radius: 16rpx;
		align-items: center;
		flex-direction: column;
	}
}
.jiantou {
	display: flex;
	justify-content: flex-end;
	margin-top: 200rpx;
	margin-right: 120rpx;
}
.jiantou_img {
	width: 170rpx;
	height: 170rpx;
}
.dian_img {
	width: 68rpx;
	height: 44rpx;
	margin: 0 16rpx;
}
.safari_img {
	width: 100rpx;
	height: 140rpx;
	margin: 0 16rpx;
}
.dian {
	margin-top: 24rpx;
	margin-left: 100rpx;
	display: flex;
	align-items: center;
}
.safari {
	margin-top: 36rpx;
	margin-left: 100rpx;
	display: flex;
	align-items: center;
	font-size: 28rpx;
}
.circle {
	width: 64rpx;
	height: 64rpx;
	background: #fc1f1f;
	border-radius: 50%;
	line-height: 64rpx;
	text-align: center;
	font-size: 40rpx;
	font-family: PingFang SC;
	font-weight: bold;
	color: #ffffff;
	margin-right: 10rpx;
}
.text {
	font-size: 32rpx;
	font-family: PingFang SC;
	font-weight: 400;
	color: #ffffff;
}
.rect {
	width: 100vw;
	height: 100vh;
}
</style>
